package com.szq.springframework;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/***
 * All rights Reserved, Designed By www.jx-lab.com
 * @Title: BeanFactory
 * @Description: Bean工厂
 * @author lixy
 * @date 2021/8/11 18:54
 * @version V1.0
 * @Copyright: www.jx-lab.com Inc. All rights reserved.
 * 注意：本内容仅限于众合景轩信息技术有限公司内部传阅，禁止外泄以及用于其他的商业目
 */
public class BeanFactory {

    private Map<String, BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<>();

    /**
     * 获取bean对象
     * @param name
     * @return
     */
    public Object getBean(String name){
        return beanDefinitionMap.get(name).getBean();
    }

    /**
     * 注册bean对象
     * @param name
     * @param beanDefinition
     */
    public void registerBeanDefinition(String name, BeanDefinition beanDefinition){
        beanDefinitionMap.put(name, beanDefinition);
    }

}
